// SentencesSet.cpp: implementation of the CSentencesSet class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SentencesSet.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
////////////////////+//////////////////////////////////////////////////

CSentencesSet::CSentencesSet()
{
	m_Sentences = NULL;
	m_Numbers = NULL;
}

CSentencesSet::~CSentencesSet()
{
	if ( m_Sentences )
	{
		delete[] m_Sentences;
	}
	if ( m_Numbers )
	{
		delete[] m_Numbers;
	}
}

HRESULT CSentencesSet::InitSentencesSEG()
{
	char filename[MAXPATH] = {0}; int i = 0; 
	CUtility utility;
	m_filename = utility.GetCurrentPathFile(_T("ini"));
	//filename = m_filename.GetBuffer();
	//m_filename.ReleaseBuffer();
	//IniFile ini( filename ); string v,s;
	//ini.setSection( "SENTENCES" );
	//m_SentencesLen = ini.readInt( ("len"), 0 );
	//m_Sentences = new SEG[ m_SentencesLen ];
	//for ( i =0 ; i < m_SentencesLen; i++)
	//{
	//	s = "s";
	//	s.append( 1 , 0x30+i );
	//	v = ini.readStr( s , "");
	//	m_Sentences[i].SetFB( &v );
	//}

	//ini.setSection( "NUMBERS" );
	//m_NumbersLen = ini.readInt( ("len"), 0 );
	//m_Numbers = new string[m_NumbersLen];
	//for ( i =0 ; i < m_NumbersLen ; i++ )
	//{
	//	s = "s";
	//	s.append( 1 , 0x30+i );
	//	v = ini.readStr( s , "");
	//	m_Numbers[i] = v;
	//}
	//ini.setSection("COLTD");
	//m_Coltdslen = ini.readInt( ("len") , 0 );
	//m_COLTDs = new string[m_Coltdslen];
	//for ( i = 0; i < m_Coltdslen ; i ++)
	//{
	//	s ="s"; s.append( 1, 0x30 + i );
	//	v = ini.readStr( s, "");
	//	m_COLTDs[i] = v;
	//}
	return S_OK;
}

LRESULT CSentencesSet::SegmentsText(CString pStr )
{
	//int  i, j , pos[2] = {string::npos, string::npos};
	//string source( pStr ) , smid;
	//for ( i = 0 ; i < m_SentencesLen; i++)
	//{
	//	pos[0] = source.find( m_Sentences[i].F , 0);
	//	if (pos[0] != string::npos){
	//		pos[0] +=  m_Sentences[i].F.length();
	//		pos[1] = source.find( m_Sentences[i].B , pos[0]);
	//		if ( pos[1] != string::npos){
	//			smid = source.substr( pos[0]  , pos[1]-pos[0] );
	//			for ( j = 0; j < m_NumbersLen; j++)
	//			{
	//				if ( m_Numbers[j] == smid)
	//				{
	//					return pos[1] + + m_Sentences[i].B.length();
	//				}
	//			}
	//		}
	//	}
	//}
	return 0;
}

LRESULT CSentencesSet::IsCOLTD(CString pstr )
{
	int i, l ; tstring source(pstr);
	for ( i = 0; i < m_Coltdslen ; i++)
	{
		l = m_COLTDs[i].length();
		//?if (m_COLTDs[i].compare(0 ,  l , source.substr(0, l)) ==0 )
		{
			return l;
		}
	}
	return 0;
}